﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Hkwl.WorldExpo.Merchant.Common;
using Hkwl.WorldExpo.Merchant.Model;
using Hkwl.WorldExpo.Merchant.Service;
using System.Globalization;

namespace Hkwl.WorldExpo.Merchant.Web
{
    public partial class Login : BaseCheckPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnLogin_Click(object sender, ImageClickEventArgs e)
        {
            string LoginName = txtLoginName.Text.Trim();
            string Password = MD5.MD5_32(txtPassword.Text.Trim());

            NxMerchant nxMerchart = ServiceLocator.IMerchantService.CheckMerchantLogin(LoginName, Password);

            if (nxMerchart != null)
            {
                Session["MerchantId"] = nxMerchart.MerchantId;
                //添加日志
                ServiceLocator.IMerchantService.CommonInsertFormatLog(Convert.ToInt32(Session["MerchantId"]),1, string.Format("商家登录成功，商家名称：{0}", nxMerchart.LoginName));
                JavaScript.WriteJs("jAlert('" + (String)GetLocalResourceObject("WELCOME_BACK") + "&nbsp;&nbsp;" + nxMerchart.LoginName + "！','" + (String)GetGlobalResourceObject("Default", "NOTE") + "','Index.aspx')", this.Page);
            }
            else
            {
                JavaScript.WriteJs("jAlert('" + (String)GetLocalResourceObject("LOGIN_ERR") + "','" + (String)GetGlobalResourceObject("Default","ALERT") + "',null)", this.Page);
            }

        }
    }
}
